#pragma once
#include "core/Processor.h"
#include "utils/Timer.h"

////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////

class MainLoop :  boost::noncopyable 
{

	typedef std::list< std::unique_ptr<IProcessor> > MainLoopProcessorList ;

private:
	long FRAMES_PER_SEC;	
	
	long CURRENT_FRAME_TIME_MILL;
	long CURRENT_FRAME_COUNTER;
	
	bool running;
	bool processorsChanged;

	MainLoopProcessorList activeProcessors;	
	Timer timer;
	

public:	

	MainLoop(void);
	virtual ~MainLoop(void);
	
	int execute(long FPS=30L);

	void add(IProcessor* processor);
	void remove(IProcessor* processor);


	void removeAll();

	inline bool isRunning() {return running;}

	inline long getCurrentFrameCounter() {return CURRENT_FRAME_COUNTER;}
	inline long getCurrentFrameTimeMillis() {return CURRENT_FRAME_TIME_MILL;}
	inline long getCurrentFPS() {return 1000/CURRENT_FRAME_TIME_MILL;}
};





